#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int sum = 0;
        int left = 0;
        int right = 0;
        int length = INT_MAX;
        for (; right < nums.size(); right++)
        {
            sum += nums[right];
            while (sum >= target)
            {
                length = min(length, right - left + 1);
                sum -= nums[left];
                left++;
            }
        }
        return length == INT_MAX ? 0 : length;
    }
};
int main()
{
    vector<int> a = { 1,2,3,4,5};
    cout<<Solution().minSubArrayLen(15, a);
}
